let arr1 = ['item1', 'item2', 'item3', 'item4', 'item5'];
let arr2 = [
    { content: 'section1', index: 0 },
    { content: 'section2', index: 2 }
]

arr2.forEach((a) => {
    //console.log(a.index)
    arr1.forEach((i, index) => {
        //console.log(index)
        if (a.index == index) {
            //console.log(i)
            arr1.splice(index, 1, [a.content, i])
        }
    })
})

console.log(arr1.flat())

//方法二
arr2.forEach()